﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.Composite.Events;
using Microsoft.Practices.Composite.Presentation.Events;

namespace EQual.MainModule.MainNavigation
{
    public class MainNavigationController : EQual.MainModule.MainNavigation.IMainNavigationController
    {
        public  INavigationView navigationView;
                private IEventAggregator eventAggregator;

        IList<EQual.Infrastructure.ModuleToken> modules;

        public MainNavigationController(INavigationView  view, IEventAggregator eventAggregator)
        {
            this.navigationView = view;
            view.Controller = this;
            this.eventAggregator = eventAggregator;

           InitaializeNavigation();
        }

        public MainNavigationController()
        {

        }

        private void InitaializeNavigation()
        {
            navigationView.DocumentsControlProcces.ItemsSource = WpfApplicationExperimental.MainManusCategoryGenerator.GetMainMenuCategoryItems("Documents");

            navigationView.EmployeeProcces.ItemsSource = WpfApplicationExperimental.MainManusCategoryGenerator.GetMainMenuCategoryItems("Personel");
            navigationView.ProjectsProcces.ItemsSource = WpfApplicationExperimental.MainManusCategoryGenerator.GetMainMenuCategoryItems("Projects");
            navigationView.FailluresProcces.ItemsSource = WpfApplicationExperimental.MainManusCategoryGenerator.GetMainMenuCategoryItems("failures");
        }

        public void AddNewModule(EQual.Infrastructure . ModuleToken token)
        {
            modules.Add(token);
        }

        #region IMainNavigationController Members


        public void NewItemSelected(object p)
        {

            eventAggregator.GetEvent<EQual.Infrastructure.NavigationViewSelected>().Publish(p.ToString ());
        }

        #endregion
    }
}
